package com.billing.gwt.client;

import java.util.Date;

import com.billing.gwt.client.data.BillingDatabase;
import com.billing.gwt.shared.BillingEntry;
import com.google.gwt.cell.client.CheckboxCell;
import com.google.gwt.cell.client.DateCell;
import com.google.gwt.cell.client.EditTextCell;
import com.google.gwt.cell.client.NumberCell;
import com.google.gwt.cell.client.TextCell;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.cellview.client.DataGrid;
import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.cellview.client.SimplePager.TextLocation;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.view.client.DefaultSelectionEventManager;
import com.google.gwt.view.client.MultiSelectionModel;
import com.google.gwt.view.client.SelectionModel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Billing implements EntryPoint {

  
	  private BillingEntryDataGrid billingEntryDGrid;
	
	  /**
	   * This is the entry point method.
	   */
	  public void onModuleLoad() {
	
		  // Billing Entry Data Grid
		  final DataGrid<BillingEntry>  dataGrid = BillingEntryDataGrid.create();
			
		  // Add Billing Entry Pager
		  SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
		  SimplePager pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
		  pager.setPageSize(5);
		  pager.setDisplay(dataGrid);
			
		  final DockLayoutPanel p = new DockLayoutPanel(Unit.PCT);
		  p.addNorth(new HTML("<h2><b>Gestion de facturas</b></h2>"), 10);
		  p.addSouth(pager,2);
		 // p.addWest(new HTML("navigation"), 10);
		  
		  TabPanel tabPanel = new TabPanel();
		  
		  final LayoutPanel aux= new LayoutPanel();
		  aux.add(dataGrid);
		  aux.setWidth("100%");
		  aux.add(pager);
		  tabPanel.add(aux,"Entradas");
		  
		  tabPanel.add(new Label("Facturas"),"Facturas");
		  p.add(tabPanel);
		  
//		  layout.setWidgetTopHeight(toolbar, 0, Unit.PX, 60, Unit.PX);
		    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
		        @Override
		        public void execute() {
		            aux.setHeight(p.getOffsetHeight() + "px");
		            
		        }
		    });
			RootLayoutPanel.get().add(p);
			
	
	  }
}

